(function(angular){
	'use strict';
	angular.module('fs.waf').controller('cda.countryGroup.viewController',viewController);
	viewController.$inject = ['$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'countryGroupService'];
	function viewController ($scope, Constants, layoutConfig, validatorConfig, gridService, authService, countryGroupService){
		var ctrl = this, countryGroupInfo = $scope.$stateParams.params;
		
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.init = function (){
			var params = {
				countryGrpCode : countryGroupInfo.countryGrpCode
			};
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.subCountry.tableConfigs.table);
			ctrl.innerGridOptions.data = 'vm.countryGroup.countrys';
			ctrl.innerGridOptions.enableRowHeaderSelection = false;
			return authService.view(params).then(function(response){
				ctrl.countryGroup = response.data || countryGroupInfo;
				ctrl.countryGroup.countrys = ctrl.countryGroup.countrys || [];
				angular.forEach(ctrl.countryGroup.countrys, function (con, key){
					if (con.dataStatus == 'V' || con.dataStatus == null) {
						con.dataStatus = 'V';
					} else {
						con.dataStatus = ctrl.countryGroup.dataStatus;
					}
				});
			},angular.noop());
		};		

	}	
})(angular);